package auto;
	import java.awt.GridBagConstraints;
	import java.awt.GridBagLayout;
	import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

	import javax.swing.BorderFactory;
	import javax.swing.ImageIcon;
	import javax.swing.JButton;
	import javax.swing.JLabel;
	import javax.swing.JPanel;
import javax.swing.border.TitledBorder;
public class Smena2Panel extends JPanel{




	

		

		/**
	 * 
	 */
	private static final long serialVersionUID = 6483361190996054509L;
		private JLabel labelIme;
		private JButton dugmePocni = null;
		private JButton dugmeZakljuci = null;
		private JButton dugmeKomentar = null;

		GridBagLayout gbl = new GridBagLayout();
		GridBagConstraints gbc = new GridBagConstraints();

		public Smena2Panel() {
			TitledBorder titledBorder = BorderFactory.createTitledBorder("Smena 2");
			setBorder(titledBorder);
			setLayout(gbl);

			add(getLabelIme());
			add(getPocniDugme());
			add(getKomentarDugme());
			add(getZakljuciDugme());
		}

		// ********************************************** geter za labelu ime i
		// prezime ulogovanog radnika
		private JLabel getLabelIme() {
			labelIme = new JLabel("Ime_Prezime2");
			// !!!!!!!!!!
			gbcXY(0, 0);
			gbc.anchor = GridBagConstraints.NORTH;
			gbc.weighty = 2;
			gbl.setConstraints(labelIme, gbc);

			return labelIme;
		}
		
		public void setLabelIme(String imePrezime){
			labelIme.setText(imePrezime);
			
		}
		
		// ********************************************** geter za Pocni dugme
		Smena2Panel s2 = this;
		
		private JButton getPocniDugme() {
			if (dugmePocni == null) {
				dugmePocni = new JButton();
				dugmePocni.setIcon(loadIcon("/icons/add.png"));
				dugmePocni.addActionListener(new ActionListener() {
					
					@Override
					public void actionPerformed(ActionEvent e) {
						LogIn lg = new LogIn(null, s2);
						lg.setVisible(true);
						lg.setAlwaysOnTop(true);
						Var.smenalog = 2;
					}
				});
				gbcXY(0, 1);
				gbc.weighty = 1;
				gbl.setConstraints(dugmePocni, gbc);
			}
			return dugmePocni;

		}

		private JButton getKomentarDugme() {
			if (dugmeKomentar == null) {
				dugmeKomentar = new JButton();
				dugmeKomentar.setIcon(loadIcon("/icons/comment.png"));
				gbcXY(0, 2);
				gbc.weighty = 1;
				gbl.setConstraints(dugmeKomentar, gbc);
			}
			return dugmeKomentar;

		}

		// ********************************************** geter za Zakljuci dugme
		private JButton getZakljuciDugme() {
			if (dugmeZakljuci == null) {
				dugmeZakljuci = new JButton();
				dugmeZakljuci.setIcon(loadIcon("/icons/remove.png"));
				gbcXY(0, 3);
				gbc.weighty = 1;
				gbl.setConstraints(dugmeZakljuci, gbc);

			}
			return dugmeZakljuci;

		}

		public void gbcXY(int x, int y) {
			gbc.gridx = x;
			gbc.gridy = y;
			gbc.insets = new Insets(10, 10, 10, 10);
		}

		public ImageIcon loadIcon(String path) {
			return new ImageIcon(getClass().getResource(path));
		}

	

}
